/**
 * 问卷调查的js api
 * @author：chengcheng
 */
import request from "@/utils/request";

/**
 * 页面中需要用到的调查类型的数据字典数据
 */
export function initSysDictData() {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/initSysDictData",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 保存或更新问卷调查的数据
 * @param {*} data
 */
export function saveOrUpdateQuestionnaireInvestigation(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 查询问卷调查的分页数据
 * @param {*} params
 */
export function queryPagesQuestionnaireInvestigation(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 根据主键对象查询问卷调查对象数据
 * @param {*} id
 */
export function getByIdQuestionnaireInvestigation(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/questionnaireInvestigation/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键获取选项数据
 * @param {*} id
 */
export function getByIdInvestigationItem(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/investigationItem/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 保存问卷调查的选项数据
 * @param {*} data
 */
export function saveOrUpdateInvestigationItem(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/investigationItem/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 查询问卷调查的选项分页数据
 * @param {*} params
 */
export function queryPagesInvestigationItem(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/investigationItem/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 根据主键id进行发布操作 发布问卷调查
 * @param {*} id
 */
export function pulishById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/questionnaireInvestigation/publshById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键id进行撤销操作 撤销问卷调查
 * @param {*} id
 */
export function cancelById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/questionnaireInvestigation/cancelById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键id删除操作 删除问卷调查
 * @param {*} id
 */
export function deleteById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/questionnaireInvestigation/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据主键id删除问卷调查中的选项数据
 * @param {*} id
 */
export function deleteByIdInvestigationItem(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/investigationItem/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 批量发布
 * @param {*} params
 */
export function batchPublishByIds(ids) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/batchPublishByIds",
    method: "get",
    params: {
      ids
    }
  });
}

/**
 * 批量取消
 * @param {*} params
 */
export function batchCancelByIds(ids) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/batchCancelByIds",
    method: "get",
    params: {
      ids
    }
  });
}

/**
 * 批量删除
 * @param {*} params
 */
export function batchDeleteByIds(ids) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/batchDeleteByIds",
    method: "get",
    params: {
      ids
    }
  });
}

/**
 * 问卷调查拷贝功能
 * @param {*} id
 * @returns
 */
export function copyById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/infoManage/questionnaireInvestigation/copyById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据qiOid查询统计数据
 * @param {*} qiOid
 * @param {*} startDate
 * @param {*} endDate
 * @returns
 */
export function countData(qiOid, startDate, endDate) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/infoManage/questionnaireInvestigation/countData",
    method: "get",
    params: {
      qiOid: qiOid,
      startDate: startDate,
      endDate: endDate
    }
  });
}
